You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't believe that periodic sync is implemented in any browser. Chrome has implemented one-shot sync, as defined in https://wicg.github.io/BackgroundSync/spec/. I believe that Mozilla is implementing one-shot as well.
Hi,
I've got a problem with requesting a periodic sync. Error message is:
Uncaught (in promise) TypeError: Cannot read property 'register' of undefined(…)
and my registration object looks like this:
ServiceWorkerRegistration {installing: null, waiting: null, active: ServiceWorker, scope: "http://localhost:3000/", onupdatefound: null…}
So it has no requested field "periodicSync"
this is my code:
if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw', { scope: '/' }); navigator.serviceWorker.ready.then(function(registration) { console.log(registration) registration.periodicSync.register({ tag: 'get-latest-news', // default: '' minPeriod: 1000, // default: 0 powerState: 'avoid-draining', // default: 'auto' networkState: 'avoid-cellular' // default: 'online' }).then(function(periodicSyncReg) { console.log("success"); }, function() { console.log("failure"); }) }); }
What am I doing wrong?
The text was updated successfully, but these errors were encountered: